package com.xhj.springbootproject.service.impl;

import com.xhj.springbootproject.service.intf.RedisClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.*;
import redis.clients.jedis.params.geo.GeoRadiusParam;
import redis.clients.jedis.params.sortedset.ZAddParams;
import redis.clients.jedis.params.sortedset.ZIncrByParams;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author ：Xionghaijun
 * @date ：Created in 2019/8/2 1:45 PM
 * @description：
 */

@Component
public class RedisClientImpl implements RedisClient {

    private final Logger logger = LoggerFactory.getLogger(RedisClientImpl.class);

    @Autowired
    private JedisPool jedisPool;

    @Override
    public String set(String key, String value) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.set(key, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String set(String key, String value, String nxxx, String expx, long time) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.set(key, value, nxxx, expx, time);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String set(String key, String value, String nxxx) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.set(key, value, nxxx);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String get(String key) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.get(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Boolean exists(String key) {
        Jedis jedis = null;
        boolean result = false;
        try {
            jedis = jedisPool.getResource();
            result = jedis.exists(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long persist(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.persist(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String type(String key) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.type(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long expire(String key, int seconds) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.expire(key, seconds);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long pexpire(String key, long milliseconds) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.pexpire(key, milliseconds);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long expireAt(String key, long unixTime) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.expireAt(key, unixTime);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long pexpireAt(String key, long millisecondsTimestamp) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.pexpireAt(key, millisecondsTimestamp);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long ttl(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.ttl(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long pttl(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.pttl(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Boolean setbit(String key, long offset, boolean value) {
        Jedis jedis = null;
        boolean result = false;
        try {
            jedis = jedisPool.getResource();
            result = jedis.setbit(key, offset, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Boolean setbit(String key, long offset, String value) {
        Jedis jedis = null;
        boolean result = false;
        try {
            jedis = jedisPool.getResource();
            result = jedis.setbit(key, offset, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Boolean getbit(String key, long offset) {
        Jedis jedis = null;
        boolean result = false;
        try {
            jedis = jedisPool.getResource();
            result = jedis.getbit(key, offset);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long setrange(String key, long offset, String value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.setrange(key, offset, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String getrange(String key, long startOffset, long endOffset) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.getrange(key, startOffset, endOffset);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String getSet(String key, String value) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.getSet(key, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long setnx(String key, String value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.setnx(key, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String setex(String key, int seconds, String value) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.setex(key, seconds, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String psetex(String key, long milliseconds, String value) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.psetex(key, milliseconds, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long decrBy(String key, long integer) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.decrBy(key, integer);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long decr(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.decr(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long incrBy(String key, long integer) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.incrBy(key, integer);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Double incrByFloat(String key, double value) {
        Jedis jedis = null;
        Double result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.incrByFloat(key, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long incr(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.incr(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long append(String key, String value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.append(key, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String substr(String key, int start, int end) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.substr(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long hset(String key, String field, String value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hset(key, field, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String hget(String key, String field) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hget(key, field);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;    }

    @Override
    public Long hsetnx(String key, String field, String value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hsetnx(key, field, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String hmset(String key, Map<String, String> hash) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hmset(key, hash);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> hmget(String key, String... fields) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hmget(key, fields);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long hincrBy(String key, String field, long value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hincrBy(key, field, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Double hincrByFloat(String key, String field, double value) {
        Jedis jedis = null;
        Double result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hincrByFloat(key, field, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Boolean hexists(String key, String field) {
        Jedis jedis = null;
        boolean result = false;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hexists(key, field);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long hdel(String key, String... field) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hdel(key, field);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long hlen(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hlen(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> hkeys(String key) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hkeys(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> hvals(String key) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hvals(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Map<String, String> hgetAll(String key) {
        Jedis jedis = null;
        Map<String, String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hgetAll(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long rpush(String key, String... string) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.rpush(key, string);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long lpush(String key, String... string) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.lpush(key, string);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long llen(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.llen(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> lrange(String key, long start, long end) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.lrange(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String ltrim(String key, long start, long end) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.ltrim(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String lindex(String key, long index) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.lindex(key, index);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String lset(String key, long index, String value) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.lset(key, index, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long lrem(String key, long count, String value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.lrem(key, count, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String lpop(String key) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.lpop(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String rpop(String key) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.rpop(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long sadd(String key, String... member) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.sadd(key, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> smembers(String key) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.smembers(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long srem(String key, String... member) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.srem(key, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String spop(String key) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.spop(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> spop(String key, long count) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.spop(key, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long scard(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.scard(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Boolean sismember(String key, String member) {
        Jedis jedis = null;
        boolean result = false;
        try {
            jedis = jedisPool.getResource();
            result = jedis.sismember(key, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String srandmember(String key) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.srandmember(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> srandmember(String key, int count) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.srandmember(key, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long strlen(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.strlen(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zadd(String key, double score, String member) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zadd(key, score, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zadd(String key, double score, String member, ZAddParams params) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zadd(key, score, member, params);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zadd(String key, Map<String, Double> scoreMembers) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zadd(key, scoreMembers);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zadd(String key, Map<String, Double> scoreMembers, ZAddParams params) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zadd(key, scoreMembers, params);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrange(String key, long start, long end) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrange(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zrem(String key, String... member) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrem(key, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Double zincrby(String key, double score, String member) {
        Jedis jedis = null;
        Double result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zincrby(key, score, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Double zincrby(String key, double score, String member, ZIncrByParams params) {
        Jedis jedis = null;
        Double result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zincrby(key, score, member, params);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zrank(String key, String member) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrank(key, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zrevrank(String key, String member) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrank(key, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrevrange(String key, long start, long end) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrange(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrangeWithScores(String key, long start, long end) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeWithScores(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrevrangeWithScores(String key, long start, long end) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeWithScores(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zcard(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zcard(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Double zscore(String key, String member) {
        Jedis jedis = null;
        Double result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zscore(key, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> sort(String key) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.sort(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> sort(String key, SortingParams sortingParameters) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.sort(key, sortingParameters);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zcount(String key, double min, double max) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zcount(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zcount(String key, String min, String max) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zcount(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrangeByScore(String key, double min, double max) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScore(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrangeByScore(String key, String min, String max) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScore(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrevrangeByScore(String key, double max, double min) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByScore(key, max, min);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrangeByScore(String key, double min, double max, int offset, int count) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScore(key, min, max, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrevrangeByScore(String key, String max, String min) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByScore(key, max, min);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrangeByScore(String key, String min, String max, int offset, int count) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScore(key, min, max, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrevrangeByScore(String key, double max, double min, int offset, int count) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByScore(key, max, min, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScoreWithScores(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScoreWithScores(key, max, min);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScoreWithScores(key, min, max, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrevrangeByScore(String key, String max, String min, int offset, int count) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByScore(key, max, min, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScoreWithScores(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByScoreWithScores(key, max, min);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max, int offset, int count) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByScoreWithScores(key, min, max, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByScoreWithScores(key, max, min, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count) {
        Jedis jedis = null;
        Set<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByScoreWithScores(key, max, min, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zremrangeByRank(String key, long start, long end) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zremrangeByRank(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zremrangeByScore(String key, double start, double end) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zremrangeByScore(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zremrangeByScore(String key, String start, String end) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zremrangeByScore(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zlexcount(String key, String min, String max) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zlexcount(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrangeByLex(String key, String min, String max) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByLex(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrangeByLex(String key, String min, String max, int offset, int count) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrangeByLex(key, min, max, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrevrangeByLex(String key, String max, String min) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByLex(key, max, min);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Set<String> zrevrangeByLex(String key, String max, String min, int offset, int count) {
        Jedis jedis = null;
        Set<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zrevrangeByLex(key, max, min, offset, count);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long zremrangeByLex(String key, String min, String max) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zremrangeByLex(key, min, max);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long linsert(String key, BinaryClient.LIST_POSITION where, String pivot, String value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.linsert(key, where, pivot, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long lpushx(String key, String... string) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.lpushx(key, string);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long rpushx(String key, String... string) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.rpushx(key, string);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> blpop(String arg) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.blpop(arg);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> blpop(int timeout, String key) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.blpop(timeout, key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> brpop(String arg) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.brpop(arg);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> brpop(int timeout, String key) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.brpop(timeout, key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long del(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.del(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public String echo(String string) {
        Jedis jedis = null;
        String result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.echo(string);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long move(String key, int dbIndex) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.move(key, dbIndex);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long bitcount(String key) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.bitcount(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long bitcount(String key, long start, long end) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.bitcount(key, start, end);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long bitpos(String key, boolean value) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.bitpos(key, value);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long bitpos(String key, boolean value, BitPosParams params) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.bitpos(key, value, params);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<Map.Entry<String, String>> hscan(String key, int cursor) {
        Jedis jedis = null;
        ScanResult<Map.Entry<String, String>> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hscan(key, cursor);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<String> sscan(String key, int cursor) {
        Jedis jedis = null;
        ScanResult<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.sscan(key, cursor);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<Tuple> zscan(String key, int cursor) {
        Jedis jedis = null;
        ScanResult<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zscan(key, cursor);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<Map.Entry<String, String>> hscan(String key, String cursor) {
        Jedis jedis = null;
        ScanResult<Map.Entry<String, String>> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hscan(key, cursor);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<Map.Entry<String, String>> hscan(String key, String cursor, ScanParams params) {
        Jedis jedis = null;
        ScanResult<Map.Entry<String, String>> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.hscan(key, cursor, params);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<String> sscan(String key, String cursor) {
        Jedis jedis = null;
        ScanResult<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.sscan(key, cursor);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<String> sscan(String key, String cursor, ScanParams params) {
        Jedis jedis = null;
        ScanResult<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.sscan(key, cursor, params);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<Tuple> zscan(String key, String cursor) {
        Jedis jedis = null;
        ScanResult<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zscan(key, cursor);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public ScanResult<Tuple> zscan(String key, String cursor, ScanParams params) {
        Jedis jedis = null;
        ScanResult<Tuple> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.zscan(key, cursor, params);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long pfadd(String key, String... elements) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.pfadd(key, elements);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public long pfcount(String key) {
        Jedis jedis = null;
        long result = 0;
        try {
            jedis = jedisPool.getResource();
            result = jedis.pfcount(key);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long geoadd(String key, double longitude, double latitude, String member) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.geoadd(key, longitude, latitude, member);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Long geoadd(String key, Map<String, GeoCoordinate> memberCoordinateMap) {
        Jedis jedis = null;
        Long result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.geoadd(key, memberCoordinateMap);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Double geodist(String key, String member1, String member2) {
        Jedis jedis = null;
        Double result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.geodist(key, member1, member2);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public Double geodist(String key, String member1, String member2, GeoUnit unit) {
        Jedis jedis = null;
        Double result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.geodist(key, member1, member2, unit);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<String> geohash(String key, String... members) {
        Jedis jedis = null;
        List<String> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.geohash(key, members);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<GeoCoordinate> geopos(String key, String... members) {
        Jedis jedis = null;
        List<GeoCoordinate> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.geopos(key, members);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit) {
        Jedis jedis = null;
        List<GeoRadiusResponse> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.georadius(key, longitude, latitude, radius, unit);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) {
        Jedis jedis = null;
        List<GeoRadiusResponse> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.georadius(key, longitude, latitude, radius, unit, param);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit) {
        Jedis jedis = null;
        List<GeoRadiusResponse> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.georadiusByMember(key, member, radius, unit);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param) {
        Jedis jedis = null;
        List<GeoRadiusResponse> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.georadiusByMember(key, member, radius, unit, param);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    @Override
    public List<Long> bitfield(String s, String... strings) {
        Jedis jedis = null;
        List<Long> result = null;
        try {
            jedis = jedisPool.getResource();
            result = jedis.bitfield(s, strings);
        } catch (Exception e) {
            logger.error("redis出错，错误信息={}", e);
        } finally {
            returnResource(jedisPool, jedis);
        }
        return result;
    }

    /**
     * 返还到连接池
     *
     * @param jedisPool
     * @param jedis
     */
    public static void returnResource(JedisPool jedisPool, Jedis jedis) {
        if (jedis != null) {
            jedisPool.returnResource(jedis);
        }
    }
}
